<?php
	$aa = URL;
	foreach($ruta as $r){ $aa.='/'.$r; }

    $sql = "select * from redirecciones where url_vieja='$aa'";
	$rs 	= $db->CacheSelectLimit($sql,1);
	$stt	= $rs->FetchRow();

    if ($stt) {
        $tipo = $stt['tipo'];
        $url  = $stt['url_nueva'];

        if ($tipo == 301) {
            $tipo = '301 Moved Permanently';    
        }
        
        Header("HTTP/1.1 $tipo");
        Header("Location: $url");
        exit();
		die();	
    }

	
/*
	//$aa = URL.'/'.$ruta[0];
	$aa = URL.'/'.$aa;

    $sql = "select * from redirecciones where url_vieja='$aa'";
	$rs 	= $db->SelectLimit($sql,1);
	$stt	= $rs->FetchRow();

    if ($stt) {
	
        $tipo = $stt['tipo'];
		$url  = $stt['url_nueva'];
		if(!empty($ruta[1]) ) { $url.='/'.$ruta[1]; }
	
        if ($tipo == 301) {
            $tipo = '301 Moved Permanently';    
        }
        
        Header("HTTP/1.1 $tipo");
        Header("Location: $url");
        exit();
        
    }
*/	
?>

